Changes to how the ScriptNode deals with "compiled in" lua scripts - #1174
Open
BuzzBurrowes wants to merge 4 commits into
Open
Changes to how the ScriptNode deals with "compiled in" lua scripts#1174BuzzBurrowes wants to merge 4 commits into
BuzzBurrowes wants to merge 4 commits into
Conversation
… make it a little easier to add new built-in scripts.
…er to add them. This may be a problem if the order of these scripts in the preset / program list needs to remain the same! I think it is OK since element saves the actual text of each script in each script node in the session file... not just a program number. This means it kind of doesn't matter what the program number of a script was when it was selected for a script node.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prior to this change, the ScriptNode had a hard coded list of 'compiled-in' LUA scripts it recognized and presented to the user in the "Factory Presets" menu. Obviously this meant that if you wanted to add a compiled-in script you had to modify the source code in scriptnode.cpp.
These changes cause the compiled in LUA scripts to be enumerated at runtime. This makes it much easier to add lua scripts to the element/scripts folder and have them picked up by the build system.
One ramification of this change is that DSP scripts should now include a 'dspName' field in the last return {...} block so that the application knows what to display in the menu. Here is an example from the testtone.lua script...
return {
type = 'DSP',
layout = layout,
prepare = prepare,
process = process,
dspName = 'Test Tone'
}
I have modified the existing LUA scripts in the scripts folder to include this field.
One note about the implementation... The new ScriptRegistry class DOES NOT open and run the lua scripts to get this return result. That seemed dangerous because it seems that could run lua code that had side effects. Instead some simple regex is used to look for the 'DSP' and 'DSPUI' types, as well as the dspName.